package com.nolon.flange.model

import androidx.room.ColumnInfo
import androidx.room.Entity
import androidx.room.PrimaryKey

@Entity(tableName = "part_table")
data class Part(
    @PrimaryKey(autoGenerate = true) val id: Int = 0,
    @ColumnInfo(name = "project_id") val projectId: Int = 0,
    @ColumnInfo(name = "solution_id") val solutionId: Int = 0,
    val quantity: Int,
    @ColumnInfo(name = "material_spec") val materialSpec: String,
    @ColumnInfo(name = "actual_material_spec") val actualSpec: Int,
    val direction: Int,
    val rounding: Boolean,
    @ColumnInfo(name = "big_holes") val bigHoles: Int = 0,
    @ColumnInfo(name = "big_padding") val bigPadding: Float = 0f,
    @ColumnInfo(name = "big_distance") val bigDistance: Float = 0f,
    @ColumnInfo(name = "small_holes") val smallHoles: Int = 0,
    @ColumnInfo(name = "small_padding") val smallPadding: Float = 0f,
    @ColumnInfo(name = "small_distance") val smallDistance: Float = 0f
) {

    override fun equals(other: Any?): Boolean {
        if (other is Part) {
            if (other.projectId == projectId
                && other.solutionId == solutionId
                && other.quantity == quantity
                && other.materialSpec == materialSpec
                && other.actualSpec == actualSpec
                && other.direction == direction
                && other.bigHoles == bigHoles
                && other.bigPadding == bigPadding
                && other.bigDistance == bigDistance
                && other.smallHoles == smallHoles
                && other.smallPadding == smallPadding
                && other.smallDistance == smallDistance
            ) return true
        }
        return super.equals(other)
    }

    companion object {
        const val DIRECTION_LENGTH = 2
        const val DIRECTION_WIDTH = 1
    }
}
